package com.toocms.jinjuhang.dialog.order_cancel

import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.view.*
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.DialogFragment
import com.toocms.jinjuhang.R
import com.toocms.jinjuhang.BR
import com.toocms.jinjuhang.databinding.DialogOrderCancelBinding

class OrderCancelDialog : DialogFragment() {

    var type: String? = null
    var orderId: String? = null
    var orderGoodsId: String? = null

    var binding: DialogOrderCancelBinding? = null
    var viewModel: OrderCancelModel? = null

    var onSucceedListener: ((tag: String?) -> Unit)? = null

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
    ): View? {
        binding = DataBindingUtil.inflate(inflater, R.layout.dialog_order_cancel, container, false)
        viewModel = OrderCancelModel(this@OrderCancelDialog)
        binding?.setVariable(BR.orderCancelModel, viewModel)
        return binding!!.root
    }

    override fun onStart() {
        super.onStart()
        dialog?.run {
            setCancelable(true)
            setCanceledOnTouchOutside(true)
            window
        }?.apply {
            setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
            setGravity(Gravity.BOTTOM)
            setLayout(
                WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.WRAP_CONTENT
            )
        }
    }

}